import request from '../../utils/request';

// 获取角色列表
export function getRoleList (params){
    return request({
        url:window.poIP+ "/auth/role",
        method: 'get',
        params: params
    });
};
// 获取机构
export function getOrgList (params){
    return request({
        url:window.poIP+ "/appbase/qryAllInsts",
        method: 'post',
        params: params
    });
};
// 获取用户列表
export function getRoleUserList (params){
    return request({
        url:window.poIP+ "/interAuth/qryExternalUsers",
        method: 'post',
        params: params
    });
};
// 新增角色
export function addRole (params){
    return request({
        url:window.poIP+ "/auth/role",
        method: 'post',
        data: params,
        headContype:true
    });
};
// 编辑角色
export function editRole (params){
    return request({
        url:window.poIP+ "/auth/role",
        method: 'PUT',
        data: params,
        headContype:true
    });
};
// 删除单个角色
export function deleteSigleRole (params){
    return request({
        url:window.poIP+ "/auth/role/"+params.id,
        method: 'DELETE',
        params: params
    });
};
// 删除批量角色
export function deleteBatchRole (params){
    return request({
        url:window.poIP+ "/auth/role",
        method: 'DELETE',
        data: params,
        headContype:true
    });
};
// 查看角色编辑数据
export function editRoleDetail (params){
    return request({
        url:window.poIP+ "/auth/role/"+params.id,
        method: 'get',
        params: params
    });
};
// 获取 app 权限列表
export function appPowerRoleList (params){
    return request({
        url:window.poIP+ "/interAuth/uapSelectResourceByRole",
        method: 'post',
        params: params
    });
};

//  app 权限保存
export function saveAppPowerRole (params){
    return request({
        url:window.poIP+ "/interAuth/saveRoleAllResource",
        method: 'PUT',
        data: params,
        headContype:true
    });
};

//****************************************** 组织架构***********************************//

// 获取组织架构
export function getOrgFrameWorkList (params){
    return request({
        url:window.poIP+ "/auth/group",
        method: 'get',
        params: params
    });
};
// 获取该机构分组号下的所有组织的列表
export function getOrgFrameWorkAllList (params){
    return request({
        url:window.poIP+ "/auth/group/getAllList",
        method: 'get',
        params: params
    });
};
// 查询人员列表
export function getPersonList (params){
    return request({
        url:window.poIP+ "/auth/group/" + params.groupId,
        method: 'get',
        params: params
    });
};
// 组织架构查询角色列表
export function getorgRoleList (params){
    return request({
        url:window.poIP+ "/auth/role/all",
        method: 'get',
        params: params
    });
};
// 新增部门
export function addDepart (params){
    return request({
        url:window.poIP+ "/auth/group",
        method: 'post',
        data: params,
        headContype:true
    });
};
// 编辑部门
export function editDepart (params){
    return request({
        url:window.poIP+ "/auth/group",
        method: 'PUT',
        data: params,
        headContype:true
    });
};
// 配置人员信息
export function configPersonInfo (params){
    console.log(params)
    return request({
        url:window.poIP+ "/auth/group/allocate/"+params.groupId,
        method: 'post',
        data: params.data,
        headContype:true

    });
};
// 获取组织机构配置人员数据
export function getConfigPersonList (params){
    return request({
        url:window.poIP+ "/interAuth/qryInstUsers",
        method: 'post',
        params: params,

    });
};
// 删除组织机构选中的人员
export function delConfigPerson (params){
    return request({
        url:window.poIP+ "/auth/group/choose/"+params.groupId,
        method: 'DELETE',
        data: params.ids,
        headContype:true

    });
};
// 删除组织机构中的部门
export function delDepart (params){
    return request({
        url:window.poIP+ "/auth/group/"+params.groupId,
        method: 'DELETE'
    });
};
// 编辑组织机构选中的人员
export function editConfigPerson (params){
    return request({
        url:window.poIP+ "/auth/group/update/"+params.groupId,
        method: 'post',
        data: params.data,
        headContype:true

    });
};
// 查看人员信息
export function lookeditConfigPerson (params){
    return request({
        url:window.poIP+ "/auth/group/allocate/"+params.groupId+'/'+params.userId,
        method: 'get'

    });
};